#ifndef _RELAYMOTOR_H_
#define _RELAYMOTOR_H_
#include "stdint.h"
#include "stm32f4xx.h"

/****************RELAY*******************/
#define RELAY1_PORT			  GPIOC
#define RELAY1_PIN			  GPIO_Pin_9
#define RELAY2_PORT			  GPIOC
#define RELAY2_PIN			  GPIO_Pin_8
#define RELAY3_PORT			  GPIOE
#define RELAY3_PIN			  GPIO_Pin_6
#define RELAY4_PORT			  GPIOC
#define RELAY4_PIN			  GPIO_Pin_2

#define RELAY5_PORT			  GPIOA
#define RELAY5_PIN			  GPIO_Pin_1
#define RELAY6_PORT			  GPIOC
#define RELAY6_PIN			  GPIO_Pin_1
#define RELAY7_PORT			  GPIOE
#define RELAY7_PIN			  GPIO_Pin_5
#define RELAY8_PORT			  GPIOE
#define RELAY8_PIN			  GPIO_Pin_4
#define RELAY9_PORT			  GPIOC
#define RELAY9_PIN			  GPIO_Pin_0

#define  RELAY1_ON()	  		GPIO_SetBits(RELAY1_PORT,RELAY1_PIN)
#define	 RELAY1_OFF()			GPIO_ResetBits(RELAY1_PORT,RELAY1_PIN)
#define	 RELAY1_TOGGLE()		GPIO_ToggleBits(RELAY1_PORT,RELAY1_PIN)

#define  RELAY2_ON()	  		GPIO_SetBits(RELAY2_PORT,RELAY2_PIN)
#define	 RELAY2_OFF()			GPIO_ResetBits(RELAY2_PORT,RELAY2_PIN)
#define	 RELAY2_TOGGLE()		GPIO_ToggleBits(RELAY2_PORT,RELAY2_PIN)

#define  RELAY3_ON()	  		GPIO_SetBits(RELAY3_PORT,RELAY3_PIN)
#define	 RELAY3_OFF()			GPIO_ResetBits(RELAY3_PORT,RELAY3_PIN)
#define	 RELAY3_TOGGLE()		GPIO_ToggleBits(RELAY3_PORT,RELAY3_PIN)

#define  RELAY4_ON()	  		GPIO_SetBits(RELAY4_PORT,RELAY4_PIN)
#define	 RELAY4_OFF()			GPIO_ResetBits(RELAY4_PORT,RELAY4_PIN)
#define	 RELAY4_TOGGLE()		GPIO_ToggleBits(RELAY4_PORT,RELAY4_PIN)

#define  RELAY5_ON()	  		GPIO_SetBits(RELAY5_PORT,RELAY5_PIN)
#define	 RELAY5_OFF()			GPIO_ResetBits(RELAY5_PORT,RELAY5_PIN)
#define	 RELAY5_TOGGLE()		GPIO_ToggleBits(RELAY5_PORT,RELAY5_PIN)

#define  RELAY6_ON()	  		GPIO_SetBits(RELAY6_PORT,RELAY6_PIN)
#define	 RELAY6_OFF()			GPIO_ResetBits(RELAY6_PORT,RELAY6_PIN)
#define	 RELAY6_TOGGLE()		GPIO_ToggleBits(RELAY6_PORT,RELAY6_PIN)

#define  RELAY7_ON()	  		GPIO_SetBits(RELAY7_PORT,RELAY7_PIN)
#define	 RELAY7_OFF()			GPIO_ResetBits(RELAY7_PORT,RELAY7_PIN)
#define	 RELAY7_TOGGLE()		GPIO_ToggleBits(RELAY7_PORT,RELAY7_PIN)

#define  RELAY8_ON()	  		GPIO_SetBits(RELAY8_PORT,RELAY8_PIN)
#define	 RELAY8_OFF()			GPIO_ResetBits(RELAY8_PORT,RELAY8_PIN)
#define	 RELAY8_TOGGLE()		GPIO_ToggleBits(RELAY8_PORT,RELAY8_PIN)

#define  RELAY9_ON()	  		GPIO_SetBits(RELAY9_PORT,RELAY9_PIN)
#define	 RELAY9_OFF()			GPIO_ResetBits(RELAY9_PORT,RELAY9_PIN)
#define	 RELAY9_TOGGLE()		GPIO_ToggleBits(RELAY9_PORT,RELAY9_PIN)

typedef enum{
	_RELAYNONE = 0,
	_RELAYONE,
	_RELAYTWO,
	_RELAYTHREE,
	_RELAYFOUR,
	_RELAYFIVE,
	_RELAYSIX,
	_RELAYSEVEN,
	_RELAYEIGHT,
	_RELAYNIGHT,
}E_RELAY_LIST;

typedef enum{
	RELAY_OFF = 0,
	RELAY_ON,
}E_RELAY_ONOFF_LIST;

typedef enum{
	RELAY_NEGATIVE = 0,
	RELAY_POSITIVE,
}E_RELAY_DIR_LIST;

void Relay_Gpio_Init(void);
void Relay_Process(uint8_t num,uint8_t onoff,uint8_t dir);
void Set_Relay(uint8_t num,uint8_t onoff,uint8_t dir);
void Relay_Ctrl(void);
#endif

